package com.weigang.config;

import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/openai")
public class OpenAIController {


    private final OpenAIService openAIService;

    public OpenAIController(OpenAIService openAIService) {
        this.openAIService = openAIService;
    }

    @GetMapping("/models")
    public String getModels() {
        return openAIService.getModels();
    }

    @PostMapping("/askGPT")
    public String askGPT(@RequestBody Map<String, String> request) {
        String prompt = request.get("prompt");
        return openAIService.askGPT(prompt);
    }

    @PostMapping("/generate")
    public String generateText(@RequestBody Map<String, String> request) {
        String prompt = request.get("prompt");
        openAIService.getCompletion(prompt);
        return "";
    }
}
